import Vue from 'vue'
import App from './App'
import uView from "uview-ui";

Vue.use(uView);
Vue.config.productionTip = false

/**
 * 页面跳转
 * @author wanlifei
 *
 * @param {Object} url 需要跳转的应用内非 tabBar 的页面的路径
 * @param {Object} animationType 窗口显示的动画效果
 * @param {Object} animationDuration 窗口动画持续时间，单位为 ms
 */
const to = (url, animationType = 'pop-in', animationDuration = 300) => {
	uni.navigateTo({
		url,
		animationType,
		animationDuration
	})
}

/**
 * 页面认证
 * @author wanlifei
 * 
 * @param {Object} url 地址
 */
const auth = (url)=> {
	if(uni.getStorageSync('userInfo')) {
		to(url)
	} else {
		uni.showToast({
			title: '请登录后操作',
			icon: 'none'
		})
	}
}
Vue.prototype.$util = {
	to,
	auth
}
App.mpType = 'app'

const app = new Vue({
    ...App
})
app.$mount()
